﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace DPMQWindowsService
{
    public class LogHelp
    {
        public static void WriteToCVTXT(string sMsg, string Machine, string SN, string BG, string ReturnMsg)
        {
            try
            {
                //string strSQL = string.Format("insert into [API_Log](Msg, Machine,operation,sn,bg,returnmsg)values(N'{0}',N'{1}','AutoLinkBG',N'{2}',N'{3}',N'{4}')", sMsg, Machine, SN, BG, ReturnMsg);
                //Src.connMetalLDB.Insert(strSQL);
            }
            catch
            {
            }


        }
        public static void WriteToServerCVTXT(string sMsg)
        {
            string sPath = @"C:\MetalAutoWIPLog\" + DateTime.Now.ToString("yyyyMM");
            string sFileFullName = sPath + @"\" +
                            DateTime.Now.ToString("yyyyMMdd").ToString() + ".csv";
            try
            {
                if (!Directory.Exists(sPath))
                {
                    Directory.CreateDirectory(sPath);
                }
                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(sFileFullName, true))
                {
                    sw.Write(sMsg);
                    sw.WriteLine("");
                    sw.Dispose();
                    sw.Close();
                }
            }
            catch
            {

            }
         
        }
    }
}